package com.handtransaction.entity;

import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class Order {
    private Integer oid;
    private Integer obid;
    private Integer osid;
    private Integer ogid;
    private Date otime;
    private String ostatus;
    private Integer onumber;
    private BigDecimal oprice;
    private String ogname;
    private String ogdetail;
    private String ogimgpath;
    private String oposition;
    private String onote;
    private String obname;
    private String osname;

    public String getObname() {
        return obname;
    }

    public void setObname(String obname) {
        this.obname = obname;
    }

    public String getOsname() {
        return osname;
    }

    public void setOsname(String osname) {
        this.osname = osname;
    }

    public Order(Integer oid, Integer obid, Integer osid, Integer ogid, Date otime, String ostatus, Integer onumber, BigDecimal oprice, String ogname, String ogdetail, String ogimgpath, String oposition, String onote, String obname, String osname) {
        this.oid = oid;
        this.obid = obid;
        this.osid = osid;
        this.ogid = ogid;
        this.otime = otime;
        this.ostatus = ostatus;
        this.onumber = onumber;
        this.oprice = oprice;
        this.ogname = ogname;
        this.ogdetail = ogdetail;
        this.ogimgpath = ogimgpath;
        this.oposition = oposition;
        this.onote = onote;
        this.obname = obname;
        this.osname = osname;
    }

    public String getOposition() {
        return oposition;
    }

    public void setOposition(String oposition) {
        this.oposition = oposition;
    }

    public String getOnote() {
        return onote;
    }

    public void setOnote(String onote) {
        this.onote = onote;
    }

    public String getOgimgpath() {
        return ogimgpath;
    }

    public void setOgimgpath(String ogimgpath) {
        this.ogimgpath = ogimgpath;
    }

    public Order(){}

    public BigDecimal getOprice() {
        return oprice;
    }

    public void setOprice(BigDecimal oprice) {
        this.oprice = oprice;
    }

    public Order(Integer oid, Integer obid, Integer osid, Integer ogid, Date otime, String ostatus, Integer onumber, BigDecimal oprice, String ogname, String ogdetail, String ogimgpath) {
        this.oid = oid;
        this.obid = obid;
        this.osid = osid;
        this.ogid = ogid;
        this.otime = otime;
        this.ostatus = ostatus;
        this.onumber = onumber;
        this.oprice = oprice;
        this.ogname = ogname;
        this.ogdetail = ogdetail;
        this.ogimgpath = ogimgpath;
    }

    public Order(Integer oid, Integer obid, Integer osid, Integer ogid, Date otime, String ostatus, Integer onumber, BigDecimal oprice, String ogname, String ogdetail, String ogimgpath, String oposition, String onote) {
        this.oid = oid;
        this.obid = obid;
        this.osid = osid;
        this.ogid = ogid;
        this.otime = otime;
        this.ostatus = ostatus;
        this.onumber = onumber;
        this.oprice = oprice;
        this.ogname = ogname;
        this.ogdetail = ogdetail;
        this.ogimgpath = ogimgpath;
        this.oposition = oposition;
        this.onote = onote;
    }

    public Order(Integer oid, Integer obid, Integer osid, Integer ogid, Date otime, String ostatus, Integer onumber, BigDecimal oprice, String ogname, String ogdetail) {
        this.oid = oid;
        this.obid = obid;
        this.osid = osid;
        this.ogid = ogid;
        this.otime = otime;
        this.ostatus = ostatus;
        this.onumber = onumber;
        this.oprice = oprice;
        this.ogname = ogname;
        this.ogdetail = ogdetail;
    }

    public String getOgname() {
        return ogname;
    }

    public void setOgname(String ogname) {
        this.ogname = ogname;
    }

    public String getOgdetail() {
        return ogdetail;
    }

    public void setOgdetail(String ogdetail) {
        this.ogdetail = ogdetail;
    }

    public Integer getOid() {
        return oid;
    }

    public void setOid(Integer oid) {
        this.oid = oid;
    }

    public Integer getObid() {
        return obid;
    }

    public void setObid(Integer obid) {
        this.obid = obid;
    }

    public Integer getOsid() {
        return osid;
    }

    public void setOsid(Integer osid) {
        this.osid = osid;
    }

    public Integer getOgid() {
        return ogid;
    }

    public void setOgid(Integer ogid) {
        this.ogid = ogid;
    }

    public String getOtime() {
        String value =null;
        //将Date类型的时间转换成指定格式的字符串
        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        value = dateFormat.format(this.otime);
        return value;
    }

    public void setOtime(){
        Date date=new Date();
        this.otime=date;
    }

    public void setOtime(String otime) {
        SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        ParsePosition pos = new ParsePosition(0);//从第一个字符开始解析
        this.otime = f.parse(otime,pos);
    }

    public String getOstatus() {
        return "已完成";
    }

    public void setOstatus(String ostatus) {
        this.ostatus = ostatus;
    }

    public Integer getOnumber() {
        return onumber;
    }

    public void setOnumber(Integer onumber) {
        this.onumber = onumber;
    }

    @Override
    public String toString() {
        return "Order{" +
                "oid=" + oid +
                ", obid=" + obid +
                ", osid=" + osid +
                ", ogid=" + ogid +
                ", otime=" + otime +
                ", ostatus='" + ostatus + '\'' +
                ", onumber=" + onumber +
                ", oprice=" + oprice +
                ", ogname='" + ogname + '\'' +
                ", ogdetail='" + ogdetail + '\'' +
                ", ogimgpath='" + ogimgpath + '\'' +
                ", oposition='" + oposition + '\'' +
                ", onote='" + onote + '\'' +
                '}';
    }
}
